/**
 * 
 */
Ext.onReady(function(){
	
	var win = new Ext.form.FormPanel({
		renderTo:Ext.getBody(),
		title:"添加人员",
		width:500,
		height:340,
		plain:true,
		frame:true,
		layout:"form",
		//defaultType:"textfield", //window的默认为"panel"
		//defaults:{anchor:"100%"},
		items:[{
			xtype:"panel",
			baseCls:"x-plain",
			style:"padding:5px",
			layout:"column",
			items:[{
				columnWidth:0.5,
				baseCls:"x-plain",
				layout:"form",
				labelWidth:55,
				defaultType:"textfield",
				//defaults:{width:160},
				defaults:{anchor:"100%"},//档设置锚点布局以后,宽度的设置就没有用了.
				items:[{
					fieldLabel:"姓名"
				},{
					fieldLabel:"年龄"
				},{
					fieldLabel:"出身日期",
					xtype:"datefield",
					format:"Y-m-d",
					//readOnly:true,
					value:'1985-11-11'
				},{
					fieldLabel:"联系电话"
				},{
					xtype:"combo",
					fieldLabel:"性别",
					triggerAction: "all",
					mode:'local',
					value:"1",
					displayField:"sex",//（如果mode='remote'则默认为 undefined，如果mode = 'local' 则默认为 'text'）。
					valueField:"id",//（如果mode='remote'则默认为 undefined，如果mode = 'local' 则默认为 'value'）。
					store:new Ext.data.JsonStore({
						fields:["id","sex"],
						data:[
							{id:"1",sex:"男"},
							{id:"0",sex:"女"}
						]
					})
//					store:new Ext.data.ArrayStore({
//						fields:["id","sex"],
//						data:[
//							["1","男"],
//							["0","女"]
//						]
//					})
				},{
					fieldLabel:"电子邮件"
				}]
			},{
				columnWidth:0.5,
				style:"padding-left:10px",
				baseCls:"x-plain",
				layout:"form",
				items:[{
					id:"grImage",
					xtype:"textfield",
					fieldLabel:"个人照片",
					inputType:"image"
					//width:160,
					//height:300
				}]
			}]
		},{
			layout:"form",
			baseCls:"x-plain",
			style:"padding-left:5px",
			defaultType:"textfield",
			labelWidth:55,
			defaults:{width:400},
			items:[{
				fieldLabel:"身份证"
			},{
				fieldLabel:"具体地址"
			},{
				xtype:"panel",
				layout:"column",
				baseCls:"x-plain",
				anchor:"100%",
				defaults:{baseCls:"x-plain"},
				items:[{
					columnWidth:.5,
					layout:"form",
					labelWidth:55,
					items:[{
						xtype:"combo",
						fieldLabel:"职位",
						anchor:"100%",
						mode:"local",
						triggerAction: "all",
						displayField:"jobs",//（如果mode='remote'则默认为 undefined，如果mode = 'local' 则默认为 'text'）。
						valueField:"id",
						store:new Ext.data.ArrayStore({
							id:"jobs_store",
							fields:["jobs","id"],
							data:[["总裁","1"],["总监","2"],["美工","3"],["程序员","4"]]					
						})
					}]
				},{
					style:"padding-left:10px",
					columnWidth:.5,
					layout:"form",
					labelWidth:55,
					//defaults:{width:400},
					items:[{
						xtype:"button",
						id:"addzw",
						text:"添加职位",
						handler:function(){
							var store = Ext.StoreMgr.get("jobs_store");
							Ext.MessageBox.prompt("输入职位名称","",function(_btm,_msg){
								if(_btm == "ok"){
									//alert(_msg);
								}
								var JobRecord = Ext.data.Record.create([{
									name:"jobs",
									name:"id"
								}]);
								//alert(JobRecord)
								store.add(new JobRecord({jobs:_msg,id:"100"}));
							})
						}
					}]
				}]
			}]
		}],
		buttons:[{
			id:"qdButton",
			text:"确定"
		},{
			text:"取消"
		}]
	});
	Ext.getCmp("qdButton").on("click",function(){
		var a =Ext.getCmp("grImage").getEl().dom;
		a.src = "http://img1.qq.com/www/pics/816/816587.gif";
	},this);
});